package com.ken.springcloud;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * <ul>
 * <li>Title: ProviderDeptApplication_8001</li>
 * <li>Description: 服务提供者 </li>
 * </ul>
 *
 * @author swc
 * @date 2021-08-26 11:36
 */
@SpringBootApplication
@EnableEurekaClient //服务注册 到 注册中心
@EnableCircuitBreaker //断路器(服务提供者)
public class ProviderDeptHystrixApplication_8001 {

    public static void main(String[] args) {
        SpringApplication.run(ProviderDeptHystrixApplication_8001.class,args);
    }

    //增加一个 Servlet (增加hystrix的监控面板  注意 actuator 完善监控是中)
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        //访问该页面就是监控页面
        servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");

        return  servletRegistrationBean;
    }

}
